-
Notifications
You must be signed in to change notification settings - Fork 58
Deeper configuration parsing and validation #515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
elbrujohalcon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments…
|
@elbrujohalcon, I'm doing "I have decided on showing results without My decision is to not throw for This:
Edit: the remaining, explicit, |
|
I've self-reviewed and (based on @bormilan's previous contributions) I enjoyed working with |
a89dc87 to
f70edb9
Compare
(since we have no other state to work with, at the moment)
... and consumers
|
Made some minor adjustment (latest commits) from adapting to |
cdf564c to
632b4d3
Compare
632b4d3 to
63d1355
Compare
elbrujohalcon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a quick review today (after a few days travelling around Europe 😎 )… I just left a nit-picky comment. I'll do a more in-depth review later.
|
I love the all new ✅ with Windows in the mix. |
I can't simply validate rules as being non-empty because it is, by default, so what I state is "you either provide a non-empty list or a valid ruleset"
| either_rules_is_nonempty_or_ruleset_is_defined(_Rules, Ruleset) when Ruleset =/= undefined -> | ||
| ok; | ||
| either_rules_is_nonempty_or_ruleset_is_defined(_Rules, _Ruleset) -> | ||
| {error, io_lib:format("either 'rules' is a non-empty list or 'ruleset' is defined.", [])}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like…
| {error, io_lib:format("either 'rules' is a non-empty list or 'ruleset' is defined.", [])}. | |
| {error, io_lib:format("each config section is expected to have either a non-empty list of 'rules' or a 'ruleset'.", [])}. |
…would be clearer.
| ok. | ||
|
|
||
| check_flag({Option, _What} = Obj) -> | ||
| table_exists() andalso ets:lookup(elvis_config, Option) =:= [Obj]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not strongly against your code, but I would've written it as…
| table_exists() andalso ets:lookup(elvis_config, Option) =:= [Obj]. | |
| try ets:lookup(elvis_config, Option) of | |
| Result -> Result =:= [Obj] | |
| catch | |
| _:badarg -> false | |
| end. |
…or even…
| table_exists() andalso ets:lookup(elvis_config, Option) =:= [Obj]. | |
| try | |
| [Obj] =:= ets:lookup(elvis_config, Option) | |
| catch | |
| _:badarg -> false | |
| end. |
| case table_exists() of | ||
| false -> | ||
| _ = ets:new(Table, [public, named_table]); | ||
| _ -> | ||
| ok | ||
| end. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering my previous comments, this function may no longer be needed, but if it stays… It has a somewhat semantic issue: Line 791 checks if elvis_config table exists, but line 793 then creates a table called Table. Either both should be parametric or the function should receive no args.
| NS = elvis_rule:ns(Rule), | ||
| Name = elvis_rule:name(Rule), | ||
| % Bypass new/ constraints. | ||
| DefKeys = maps:keys(NS:default(Name)) ++ [ignore], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| DefKeys = maps:keys(NS:default(Name)) ++ [ignore], | |
| DefKeys = [ignore | maps:keys(NS:default(Name))], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a bunch of comments here and there… instead of making a formal review, mostly because I was not really conducting a review… just reading the code diagonally :)
In other words: A little bit of nit-picking, I hope you don't mind 🫣
elbrujohalcon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I finally had time to do a full review. All my previous comments stay, and I added yet another nit-picky one. Once all are addressed, this is mergeable to me.
Excellent job, as usual, @paulo-ferraz-oliveira !!
| ), | ||
| default_for(Key); | ||
| {ok, Value} -> | ||
| elvis_utils:debug("value for key '~s' found in application environment", [Key]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| elvis_utils:debug("value for key '~s' found in application environment", [Key]), | |
| elvis_utils:debug("value for key '~s' (~p) found in application environment", [Key, Value]), |
|
@paulo-ferraz-oliveira what's the status of this PR? Are you still working on it? |
|

Description
This pull request is all about:
First of all, I want to acknowledge this is a big change and some (much?) stuff can change before it's considered for merging.
Two things stand out, to me:
rebar3_lintandelvisin tandem with this, before it's considered for merging, because this a. touches on the API the aforementioned use, b. hopefully simplifies and gives utilities for a more unified experience in the Elvis ecosystem.Required changes
rebar3_lint: Adapt to newelvis_coreconfiguration validation project-fifo/rebar3_lint#72elvis: Adapt to newelvis_coreconfiguration validation elvis#596throwing (kind of the current behaviour which prints sometimes and throws sometimes), and adapted tests to thatCloses #438.
Closes #439.
Further considerations
As always: